import MySQLdb   
from cs.configfile_read import *
'''
#office mysql configretion
def mysql_connect():
    host="10.40.0.201"
    port=3306
    user="root"
    password="5531248"
    dbname="cloud"
    conn = MySQLdb.connect(host=host,port=port,user=user,passwd=password,db=dbname)
    cursor = conn.cursor()
    return cursor
''' 
#home mysql configretion
def mysql_connect():
    global file
    file=''
    pacth=os.path.abspath('.')
    f2='F:\code\cs-bs\cs\db.ini'
    f1='/home/cs-bs/cs/db.ini'
    for i in (f1,f2):
        if os.path.exists(i):
            file=i
    if file == '':
        print 'not find the file'
        sys.exit()
    db=Db_Connector(file)
    dbname=db.get_dbname()
    db_host=db.get_host()
    db_port=db.get_db_port()
    db_user=db.get_db_user()
    db_password=db.get_db_pwd()
    #print "dsafasdfsdafsadfasdf",dbname,db_host,db_port,db_user
    conn = MySQLdb.connect(host=db_host,port=db_port,user=db_user,passwd=db_password,db=dbname)
    cursor = conn.cursor()
    return cursor